package cn.tsinghua.comsmacitccntsinghua.boardconfig;

import android.content.Context;
import android.util.Log;

import cn.Port.myserialport.PortSend;
import cn.Port.myserialport.SerialPortUtil;
import cn.Port.myserialport.controll.BoardController;
import cn.tsinghua.comsmacitccntsinghua.bean.BaseDataInfo;
import cn.tsinghua.comsmacitccntsinghua.utils.StringUtil;

/**
 * 程序启动时初始化板子参数
 *    通知底层登录成功
 *    通知底层退出登录
 * 1. 投口延时关闭时间
 * 2. 除臭延时时间
 * 3. 推杆动作时间
 * 4. 推杆电流阈值
 */
public class StartUpControl {
    private Context context;
    private BaseDataInfo.DataBean.DeviceBean device;
   private BoardController boardController;

    public StartUpControl(Context context,BoardController mBoardController) {
        this.context = context;
        this.boardController = mBoardController;
    }

    public void sendToBoardInitData(BaseDataInfo.DataBean.DeviceBean device){

        //投口延时关闭时间设置
        if (StringUtil.isEmptyStr(device.getCloseTime())){
            boardController.setMouthDelayClose(""+device.getCloseTime());
        }else {
            boardController.setMouthDelayClose("10");
        }

        //除臭延时时间

        boardController.setDeodorizationDelay(""+device.getSterilizationTime());
        //推杆动作时间
        if (StringUtil.isEmptyStr(device.getActuationTime())){
            boardController.setPushTime(""+device.getActuationTime());
        }else {
            boardController.setPushTime("10");
        }

        //推杆电流阈值
        boardController.setMaxCurrent(""+device.getCurrentValue());
        //设置照明
        //TODO 照明控制已取消
        boardController.setTopLight(1);
    }



}
